package com.lx.websockt;


import com.lx.websockt.bean.WebsocktPropertise;
import com.lx.websockt.biz.DefaultMsgSender;
import com.lx.websockt.biz.IMsgSender;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@AutoConfiguration
@ComponentScan("com.lx.websockt")
//  matchIfMissing = true        没有enable 默认打开
@ConditionalOnProperty(prefix = "websockt", name = "enable")
@EnableConfigurationProperties(WebsocktPropertise.class)
public class WebsocktConfigration{

    // 启用WebSocket支持 服务端点管理
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {

        return new ServerEndpointExporter();
    }

    @Bean
    @ConditionalOnMissingBean
    public IMsgSender msgSender() {
        return new DefaultMsgSender();
    }

}
